package com.bey.xjj;

import java.io.IOException;

import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;

/**
 * author: gfc 
 * mail:117064092@qq.com
 * 
 */
public class JsonReader {

	public static <T> T fetchObject(String object, Class<T> objectType) throws JsonParseException, JsonMappingException, IOException {
		ObjectMapper mapper = new ObjectMapper();
		T t = mapper.readValue(object, objectType);
		return t;
	}

	public static String fetchStringByjackson(Object object) throws JsonGenerationException, JsonMappingException, IOException {
		ObjectMapper mapper = new ObjectMapper();
		return mapper.writeValueAsString(object);
	}

}
